Page({
  onShareAppMessage() {
    return {
      title: 'swiper',
      path: 'page/component/pages/swiper/swiper'
    }
  },

  data: {
    background: [
      //图片地址
      '//img12.360buyimg.com/ddimg/jfs/t1/126006/36/13085/167501/5f682bbdE7adf2a20/72a97d7721dd815f.png', 
      '//img13.360buyimg.com/ddimg/jfs/t1/137915/20/8975/166433/5f682bbdE27ddaef6/4a4d268797564582.png',
      '//img13.360buyimg.com/ddimg/jfs/t1/112212/15/18243/156779/5f682bbdE2982c779/3f2744aa67e810d9.png',
      '//img12.360buyimg.com/ddimg/jfs/t1/124970/37/13172/168584/5f682bbdE1f454605/ebbd665b2d8eece3.png',
      '//img11.360buyimg.com/ddimg/jfs/t1/144531/19/9034/146894/5f682bbdEf3d9b8d7/ae76d569e9918be2.png',
      '//img10.360buyimg.com/ddimg/jfs/t1/114536/7/18381/174303/5f682bbdE60e6fdd7/bc719424b54279b8.png'],
      //是否采用衔接滑动  
      circular: true,
      //是否显示画板指示点  
      indicatorDots: true,
      //选中点的颜色  
      indicatorcolor: "#000",
      //是否竖直  
      vertical: false,
      //是否自动切换  
      autoplay: true,
      //自动切换的间隔
      interval: 2500,
      //滑动动画时长毫秒  
      duration: 100,
      //所有图片的高度  
      imgheights: [],
      //图片宽度 
      imgwidth: 750,
      //默认  
      current: 0
  },
  imageLoad: function (e) {//获取图片真实宽度  
    var imgwidth = e.detail.width,
      imgheight = e.detail.height,
      //宽高比  
      ratio = imgwidth / imgheight;
    //计算的高度值  
    var viewHeight = 750 / ratio;
    var imgheight = viewHeight;
    var imgheights = this.data.imgheights;
    //把每一张图片的对应的高度记录到数组里  
    imgheights[e.target.dataset.id] = imgheight;
    this.setData({
      imgheights: imgheights
    })
  },
  bindchange: function (e) {
    // console.log(e.detail.current)
    this.setData({ current: e.detail.current })
  },
  changeIndicatorDots() {
    this.setData({
      indicatorDots: !this.data.indicatorDots
    })
  },

  changeAutoplay() {
    this.setData({
      autoplay: !this.data.autoplay
    })
  },

  intervalChange(e) {
    this.setData({
      interval: e.detail.value
    })
  },

  durationChange(e) {
    this.setData({
      duration: e.detail.value
    })
  }
})
